﻿
using System.Windows.Controls;
using UnifiedTool.Model;
using UnifiedTool.ViewModel;

namespace UnifiedTool.UIControl.DiyUserControl
{
    /// <summary>
    /// RankingItem.xaml 的交互逻辑
    /// </summary>
    public partial class RankingItem : UserControl
    {
        private MusicRanking musicRanking = new();

        public RankingItem()
        {
            InitializeComponent();
            
            musicRanking.MusicRankingItems.Add(new MusicInfo() { Id=1, Title= "恶作剧", Artist= "未知", Description="",Uri= "D:\\data\\audio\\恶作剧.wav",Cover= "D:\\data\\audio\\2d13uypj.png" });
            musicRanking.MusicRankingItems.Add(new MusicInfo() { Id=2, Title= "恶作剧", Artist= "未知", Description="",Uri= "D:\\data\\audio\\恶作剧.wav",Cover = "D:\\data\\audio\\2d13uypj.png" });
            musicRanking.MusicRankingItems.Add(new MusicInfo() { Id=3, Title= "99999999999999999999999999", Artist= "99999999999999999999999999", Description="",Uri= "D:\\data\\audio\\恶作剧.wav",Cover = "http://www.www.com" });
            DataContext = musicRanking;
            System.Diagnostics.Debug.WriteLine("顺利加载");


        }

        private void SongTitle_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var music = (sender as Label)?.DataContext as MusicInfo;
            if (music != null )
            {
                MediaMetadata.addNewMusicItems(new MusicInfo(music.Id, music.Title, music.Artist, music.Description,music.Uri,music.Cover));
            }
        }
    }
}
